<?php
namespace Wechat\Controller;

use \Michelf\MarkdownExtra;

class AjaxController extends AjaxBaseController {
	function __construct() {
		header('Access-Control-Allow-Origin: *');
		header('Access-Control-Allow-Methods: OPTIONS,GET,HEAD,POST,PUT,DELETE');
	}
	public function index() {
		$this->resp('hello');
	}
	public function article_list() {
		$offest = I('get.offest', 0, 'intval');
		$pages = I('get.pages', 15, 'intval');
		$return['total'] = M('WxArticle')->where(['status' => 1])->count();
		if ($offest >= $return['total'] ||  $offest < 0 || $pages <= 0) {
			$this->resp('', 'out of the page', 0);
		}
		$end = $offest + $pages;
		$return['list'] = M('WxArticle')->field('id, title, add_time, view_num, status, uid')->where(['status' => 1])->limit($offest . ',' . $end)->select();
		$this->resp($return);
	}
	public function article() {
		
	}
}